package de.alfenory.autobill.entity;

import java.util.*;

/**
 *
 * @author alefen
 */
public class OrderItem {
    String description;
    double quantity;
    double price;
    String unit;
    String partId;
    boolean addServicePeriod;
    Date date;
    Integer id;
    Double send;

    public OrderItem(String description, double quantity, double price, String unit, String partId, boolean addServicePeriod, Date date) {
        this.description = description;
        this.quantity = quantity;
        this.price = price;
        this.unit = unit;
        this.partId = partId;
        this.addServicePeriod = addServicePeriod;
        this.date = date;
        this.id = null;
        this.send = 0.0;
    }
    
    public OrderItem(String description, double quantity, double price, String unit, String partId, boolean addServicePeriod, Date date, Integer id, Double send) {
        this.description = description;
        this.quantity = quantity;
        this.price = price;
        this.unit = unit;
        this.partId = partId;
        this.addServicePeriod = addServicePeriod;
        this.date = date;
        this.id = id;
        this.send = send;
    }
    
    public OrderItem(String description, double quantity, double price, String unit, String partId, Integer id, Double send) {
        this.description = description;
        this.quantity = quantity;
        this.price = price;
        this.unit = unit;
        this.partId = partId;
        this.addServicePeriod = true;
        this.date = null;
        this.id = id;
        this.send = send;
    }
    
    public OrderItem(String description, double quantity, double price, String unit, String partId) {
        this.description = description;
        this.quantity = quantity;
        this.price = price;
        this.unit = unit;
        this.partId = partId;
        this.addServicePeriod = true;
        this.date = null;
        this.id = null;
        this.send = 0.0;
    }
    
    public String getDescription() {
        return description;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public double getPrice() {
        return price;
    }

    public double getQuantity() {
        return quantity;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public void setQuantity(double quantity) {
        this.quantity = quantity;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getPartId() {
        return partId;
    }

    public Date getDate() {
        return date;
    }

    public boolean isAddServicePeriod() {
        return addServicePeriod;
    }

    public void setAddServicePeriod(boolean addServicePeriod) {
        this.addServicePeriod = addServicePeriod;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public void setPartId(String partId) {
        this.partId = partId;
    }

    public Double getSend() {
        return send;
    }

    public void setSend(Double send) {
        this.send = send;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 73 * hash + Objects.hashCode(this.description);
        hash = 73 * hash + (int) (Double.doubleToLongBits(this.quantity) ^ (Double.doubleToLongBits(this.quantity) >>> 32));
        hash = 73 * hash + (int) (Double.doubleToLongBits(this.price) ^ (Double.doubleToLongBits(this.price) >>> 32));
        hash = 73 * hash + Objects.hashCode(this.unit);
        hash = 73 * hash + Objects.hashCode(this.partId);
        hash = 73 * hash + (this.addServicePeriod ? 1 : 0);
        hash = 73 * hash + Objects.hashCode(this.date);
        hash = 73 * hash + Objects.hashCode(this.id);
        hash = 73 * hash + (int) (Double.doubleToLongBits(this.send) ^ (Double.doubleToLongBits(this.send) >>> 32));;
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final OrderItem other = (OrderItem) obj;
        if (!Objects.equals(this.description, other.description)) {
            return false;
        }
        if (Double.doubleToLongBits(this.quantity) != Double.doubleToLongBits(other.quantity)) {
            return false;
        }
        if (Double.doubleToLongBits(this.price) != Double.doubleToLongBits(other.price)) {
            return false;
        }
        if (!Objects.equals(this.unit, other.unit)) {
            return false;
        }
        if (!Objects.equals(this.partId, other.partId)) {
            return false;
        }
        if (this.addServicePeriod != other.addServicePeriod) {
            return false;
        }
        if (!Objects.equals(this.date, other.date)) {
            return false;
        }
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        if (Double.doubleToLongBits(this.send) != Double.doubleToLongBits(other.send)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "OrderItem{" + "description=" + description + ", quantity=" + quantity + ", price=" + price + ", unit=" + unit + ", partId=" + partId + ", addServicePeriod=" + addServicePeriod + ", date=" + date + ", id=" + id + ", send=" + send + '}';
    }
}